import React from 'react'
class SonC extends React.Component { 
    render() {
        return (
            <div>
                {this.props.msg}
                <button onClick={()=>this.props.change('SonC')}>SonC</button>
            </div>
        )
    }
}
function SonF({ msg,change}) {
    return (
        <div>
            {msg}
            <button onClick={()=>change('SonF')}>SonF</button>
        </div>
    )
}
export class Test9 extends React.Component {
    state = { 
        msg: '父组件值'
    }
    change=(value)=>{
        this.setState({
            msg:value
        })
    } 
    render() {
        return (
            <div className="area">
                <h1>9.组件通信-兄弟</h1>
                <SonC msg={this.state.msg} change={this.change}/>
                <SonF msg={this.state.msg} change={this.change}/>
            </div>
        )
    }
}